package com.yuwei.main.tab

import android.content.Context
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.ImageView
import androidx.annotation.DrawableRes
import androidx.core.content.ContextCompat
import com.yuwei.main.R
import me.majiajie.pagerbottomtabstrip.item.BaseTabItem


class RoundTabView : BaseTabItem {
    private lateinit var imageView: ImageView

    private lateinit var mIcon: Drawable


    constructor(context: Context): super(context){
        initView(context)
    }

    constructor(context: Context, attrs: AttributeSet?): super(context, attrs){
        initView(context)
    }

    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int): super(context, attrs, defStyleAttr){
       initView(context)
    }

    private fun initView(context: Context) {
        //加载布局
        LayoutInflater.from(context).inflate(R.layout.tab_round_layout, this, true)
        //初始化组件
        imageView = findViewById(R.id.tab_icon)
    }

    fun initData(@DrawableRes icon: Int){
        //获取图标
         mIcon = ContextCompat.getDrawable(context, icon)!!
    }


    override fun setChecked(checked: Boolean) {
        imageView.setImageDrawable(mIcon)
    }

    override fun setMessageNumber(number: Int) {
    }

    override fun setHasMessage(hasMessage: Boolean) {
    }

    override fun setTitle(title: String?) {
    }

    override fun setDefaultDrawable(drawable: Drawable?) {
        imageView.setImageDrawable(drawable)
    }

    override fun setSelectedDrawable(drawable: Drawable?) {
        imageView.setImageDrawable(drawable)
    }

    override fun getTitle(): String {
        return ""
    }


}